package com.js.purs.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.js.purs.domain.PurBindCdd;
import com.js.purs.service.IPurBindCddService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 候选人列表Controller
 * 
 * @author lzq
 * @date 20240707
 */
@RestController
@RequestMapping("/cdd")
public class PurBindCddController extends BaseController
{
    @Autowired
    private IPurBindCddService purBindCddService;

    /**
     * 查询候选人列表列表
     */

    @GetMapping("/list")
    public TableDataInfo list(PurBindCdd purBindCdd)
    {
        startPage();
        List<PurBindCdd> list = purBindCddService.selectPurBindCddList(purBindCdd);
        return getDataTable(list);
    }

    @PostMapping("/getListByBinCode")
    public AjaxResult getListByBinCode(@RequestBody PurBindCdd purBindCdd)
    {

        List<PurBindCdd> list = purBindCddService.selectPurBindCddList(purBindCdd);
        return success(list);
    }


    /**
     * 导出候选人列表列表
     */
    @RequiresPermissions("purs:cdd:export")
    @Log(title = "候选人列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PurBindCdd purBindCdd)
    {
        List<PurBindCdd> list = purBindCddService.selectPurBindCddList(purBindCdd);
        ExcelUtil<PurBindCdd> util = new ExcelUtil<PurBindCdd>(PurBindCdd.class);
        util.exportExcel(response, list, "候选人列表数据");
    }

    /**
     * 获取候选人列表详细信息
     */
    @RequiresPermissions("purs:cdd:query")
    @GetMapping(value = "/{cddId}")
    public AjaxResult getInfo(@PathVariable("cddId") Long cddId)
    {
        return success(purBindCddService.selectPurBindCddByCddId(cddId));
    }

    /**
     * 新增候选人列表
     */
    @RequiresPermissions("purs:cdd:add")
    @Log(title = "候选人列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PurBindCdd purBindCdd)
    {
        return toAjax(purBindCddService.insertPurBindCdd(purBindCdd));
    }

    /**
     * 修改候选人列表
     */
    @RequiresPermissions("purs:cdd:edit")
    @Log(title = "候选人列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PurBindCdd purBindCdd)
    {
        return toAjax(purBindCddService.updatePurBindCdd(purBindCdd));
    }

    /**
     * 删除候选人列表
     */
    @RequiresPermissions("purs:cdd:remove")
    @Log(title = "候选人列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cddIds}")
    public AjaxResult remove(@PathVariable Long[] cddIds)
    {
        return toAjax(purBindCddService.deletePurBindCddByCddIds(cddIds));
    }
}
